/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-1 = 'agency.aliyuncs.com',
    ap-northeast-2-pop = 'agency.aliyuncs.com',
    ap-south-1 = 'agency.aliyuncs.com',
    ap-southeast-2 = 'agency.aliyuncs.com',
    ap-southeast-3 = 'agency.aliyuncs.com',
    ap-southeast-5 = 'agency.aliyuncs.com',
    cn-beijing = 'agency.aliyuncs.com',
    cn-beijing-finance-1 = 'agency.aliyuncs.com',
    cn-beijing-finance-pop = 'agency.aliyuncs.com',
    cn-beijing-gov-1 = 'agency.aliyuncs.com',
    cn-beijing-nu16-b01 = 'agency.aliyuncs.com',
    cn-chengdu = 'agency.aliyuncs.com',
    cn-edge-1 = 'agency.aliyuncs.com',
    cn-fujian = 'agency.aliyuncs.com',
    cn-haidian-cm12-c01 = 'agency.aliyuncs.com',
    cn-hangzhou = 'agency.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'agency.aliyuncs.com',
    cn-hangzhou-finance = 'agency.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'agency.aliyuncs.com',
    cn-hangzhou-test-306 = 'agency.aliyuncs.com',
    cn-hongkong = 'agency.aliyuncs.com',
    cn-hongkong-finance-pop = 'agency.aliyuncs.com',
    cn-huhehaote = 'agency.aliyuncs.com',
    cn-huhehaote-nebula-1 = 'agency.aliyuncs.com',
    cn-north-2-gov-1 = 'agency.aliyuncs.com',
    cn-qingdao = 'agency.aliyuncs.com',
    cn-qingdao-nebula = 'agency.aliyuncs.com',
    cn-shanghai = 'agency.aliyuncs.com',
    cn-shanghai-et15-b01 = 'agency.aliyuncs.com',
    cn-shanghai-et2-b01 = 'agency.aliyuncs.com',
    cn-shanghai-finance-1 = 'agency.aliyuncs.com',
    cn-shanghai-inner = 'agency.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'agency.aliyuncs.com',
    cn-shenzhen = 'agency.aliyuncs.com',
    cn-shenzhen-finance-1 = 'agency.aliyuncs.com',
    cn-shenzhen-inner = 'agency.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'agency.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'agency.aliyuncs.com',
    cn-wuhan = 'agency.aliyuncs.com',
    cn-wulanchabu = 'agency.aliyuncs.com',
    cn-yushanfang = 'agency.aliyuncs.com',
    cn-zhangbei = 'agency.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'agency.aliyuncs.com',
    cn-zhangjiakou = 'agency.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'agency.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'agency.aliyuncs.com',
    eu-central-1 = 'agency.aliyuncs.com',
    eu-west-1 = 'agency.aliyuncs.com',
    eu-west-1-oxs = 'agency.aliyuncs.com',
    me-east-1 = 'agency.aliyuncs.com',
    rus-west-1-pop = 'agency.aliyuncs.com',
    us-east-1 = 'agency.aliyuncs.com',
    us-west-1 = 'agency.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('agency', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateBpmsRecordRequest {
  bpmsParamJson?: string(name='BpmsParamJson'),
  bpmsType?: string(name='BpmsType'),
  partnerId?: long(name='PartnerId'),
  remark?: string(name='Remark'),
}

model CreateBpmsRecordResponseBody = {
  code?: string(name='Code'),
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model CreateBpmsRecordResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateBpmsRecordResponseBody(name='body'),
}

async function createBpmsRecordWithOptions(request: CreateBpmsRecordRequest, runtime: Util.RuntimeOptions): CreateBpmsRecordResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.bpmsParamJson)) {
    query['BpmsParamJson'] = request.bpmsParamJson;
  }
  if (!Util.isUnset(request.bpmsType)) {
    query['BpmsType'] = request.bpmsType;
  }
  if (!Util.isUnset(request.partnerId)) {
    query['PartnerId'] = request.partnerId;
  }
  if (!Util.isUnset(request.remark)) {
    query['Remark'] = request.remark;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateBpmsRecord',
    version = '2020-03-24',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createBpmsRecord(request: CreateBpmsRecordRequest): CreateBpmsRecordResponse {
  var runtime = new Util.RuntimeOptions{};
  return createBpmsRecordWithOptions(request, runtime);
}

model CreateBpmsResultRequest {
  applyStatus?: string(name='ApplyStatus'),
  bpmsResultId?: string(name='BpmsResultId'),
}

model CreateBpmsResultResponseBody = {
  code?: string(name='Code'),
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model CreateBpmsResultResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateBpmsResultResponseBody(name='body'),
}

async function createBpmsResultWithOptions(request: CreateBpmsResultRequest, runtime: Util.RuntimeOptions): CreateBpmsResultResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.applyStatus)) {
    query['ApplyStatus'] = request.applyStatus;
  }
  if (!Util.isUnset(request.bpmsResultId)) {
    query['BpmsResultId'] = request.bpmsResultId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateBpmsResult',
    version = '2020-03-24',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createBpmsResult(request: CreateBpmsResultRequest): CreateBpmsResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return createBpmsResultWithOptions(request, runtime);
}

model GetCustomerRebateTypeRequest {
  siteId?: string(name='SiteId'),
  transferUid?: long(name='TransferUid'),
}

model GetCustomerRebateTypeResponseBody = {
  code?: string(name='Code'),
  fxUserInfoExt?: {
    customerRebateType?: int32(name='CustomerRebateType'),
    distributionRebateType?: int32(name='DistributionRebateType'),
    isSub?: int32(name='IsSub'),
    kpId?: long(name='KpId'),
    level?: int32(name='Level'),
    parentUid?: long(name='ParentUid'),
    subUserCount?: int32(name='SubUserCount'),
  }(name='FxUserInfoExt'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GetCustomerRebateTypeResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetCustomerRebateTypeResponseBody(name='body'),
}

async function getCustomerRebateTypeWithOptions(request: GetCustomerRebateTypeRequest, runtime: Util.RuntimeOptions): GetCustomerRebateTypeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.siteId)) {
    query['SiteId'] = request.siteId;
  }
  if (!Util.isUnset(request.transferUid)) {
    query['TransferUid'] = request.transferUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetCustomerRebateType',
    version = '2020-03-24',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getCustomerRebateType(request: GetCustomerRebateTypeRequest): GetCustomerRebateTypeResponse {
  var runtime = new Util.RuntimeOptions{};
  return getCustomerRebateTypeWithOptions(request, runtime);
}

model QueryBpmsListRequest {
  auditStatus?: string(name='AuditStatus'),
  bpmsType?: string(name='BpmsType'),
  customerName?: string(name='CustomerName'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  partnerId?: long(name='PartnerId'),
  timeEnd?: string(name='TimeEnd'),
  timeStart?: string(name='TimeStart'),
}

model QueryBpmsListResponseBody = {
  code?: string(name='Code'),
  list?: {
    list?: [ 
    {
      applyRemarks?: string(name='ApplyRemarks'),
      applyTime?: string(name='ApplyTime'),
      auditStatus?: int32(name='AuditStatus'),
      customerName?: string(name='CustomerName'),
      customerRptType?: int32(name='CustomerRptType'),
      expireTime?: string(name='ExpireTime'),
      id?: long(name='Id'),
      partnerPk?: long(name='PartnerPk'),
    }
  ](name='list')
  }(name='List'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  total?: int32(name='Total'),
}

model QueryBpmsListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryBpmsListResponseBody(name='body'),
}

async function queryBpmsListWithOptions(request: QueryBpmsListRequest, runtime: Util.RuntimeOptions): QueryBpmsListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.auditStatus)) {
    query['AuditStatus'] = request.auditStatus;
  }
  if (!Util.isUnset(request.bpmsType)) {
    query['BpmsType'] = request.bpmsType;
  }
  if (!Util.isUnset(request.customerName)) {
    query['CustomerName'] = request.customerName;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.partnerId)) {
    query['PartnerId'] = request.partnerId;
  }
  if (!Util.isUnset(request.timeEnd)) {
    query['TimeEnd'] = request.timeEnd;
  }
  if (!Util.isUnset(request.timeStart)) {
    query['TimeStart'] = request.timeStart;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryBpmsList',
    version = '2020-03-24',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryBpmsList(request: QueryBpmsListRequest): QueryBpmsListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryBpmsListWithOptions(request, runtime);
}

model TransferResellerToUserRequest {
  empId?: string(name='EmpId'),
  realName?: string(name='RealName'),
  siteId?: string(name='SiteId'),
  transferUid?: long(name='TransferUid'),
}

model TransferResellerToUserResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  msg?: string(name='Msg'),
  requestId?: string(name='RequestId'),
}

model TransferResellerToUserResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TransferResellerToUserResponseBody(name='body'),
}

async function transferResellerToUserWithOptions(request: TransferResellerToUserRequest, runtime: Util.RuntimeOptions): TransferResellerToUserResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.empId)) {
    query['EmpId'] = request.empId;
  }
  if (!Util.isUnset(request.realName)) {
    query['RealName'] = request.realName;
  }
  if (!Util.isUnset(request.siteId)) {
    query['SiteId'] = request.siteId;
  }
  if (!Util.isUnset(request.transferUid)) {
    query['TransferUid'] = request.transferUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TransferResellerToUser',
    version = '2020-03-24',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function transferResellerToUser(request: TransferResellerToUserRequest): TransferResellerToUserResponse {
  var runtime = new Util.RuntimeOptions{};
  return transferResellerToUserWithOptions(request, runtime);
}

model TransferUserToResellerRequest {
  empId?: string(name='EmpId'),
  parentUid?: long(name='ParentUid'),
  realName?: string(name='RealName'),
  siteId?: string(name='SiteId'),
  transferUid?: long(name='TransferUid'),
}

model TransferUserToResellerResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  msg?: string(name='Msg'),
  requestId?: string(name='RequestId'),
}

model TransferUserToResellerResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TransferUserToResellerResponseBody(name='body'),
}

async function transferUserToResellerWithOptions(request: TransferUserToResellerRequest, runtime: Util.RuntimeOptions): TransferUserToResellerResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.empId)) {
    query['EmpId'] = request.empId;
  }
  if (!Util.isUnset(request.parentUid)) {
    query['ParentUid'] = request.parentUid;
  }
  if (!Util.isUnset(request.realName)) {
    query['RealName'] = request.realName;
  }
  if (!Util.isUnset(request.siteId)) {
    query['SiteId'] = request.siteId;
  }
  if (!Util.isUnset(request.transferUid)) {
    query['TransferUid'] = request.transferUid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TransferUserToReseller',
    version = '2020-03-24',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function transferUserToReseller(request: TransferUserToResellerRequest): TransferUserToResellerResponse {
  var runtime = new Util.RuntimeOptions{};
  return transferUserToResellerWithOptions(request, runtime);
}

